package com.libg.cn.linearsearch;

import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 线性查找
 */
@Builder
public class LinearSearch {

    public static int linearSearch(int[] soursearrs, int target) {
        for (int i = 0; i < soursearrs.length; ++i)
            if (target == soursearrs[i])
                return i;
        return -1;
    }

    public static <E> int search(E[] data, E target) {
        for (int i = 0; i < data.length; ++i)
            if (data[i].equals(target))
                return i;
        return -1;
    }

}
